﻿using BLL.Interface;
using Common.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Model.DTO.Member;
using Model.DTO.Public.GetList;
using Model.DTO.Public.OperateId;
using System.Data;

namespace TianXiaHuiForumManagementSystem.Controllers.Admin
{
    [Route("Admin/[controller]")]
    [ApiController]
    public class MemberController : ControllerBase
    {
        private readonly IMemberBLL _memberBLL;
        public MemberController(IMemberBLL memberBLL)
        {
            _memberBLL = memberBLL;
        }
        /// <summary>
        /// 添加会员
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("AddMember")]
        public async Task<string> AddMember(AddMemberDTO param)
        {
            var result = await _memberBLL.AddMember(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 删除会员
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("DeleteMember")]
        public async Task<string> DeleteMember(OperateIdDTO_LONG param)
        {
            var result = await _memberBLL.DeleteMember(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 编辑会员
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("EditMember")]
        public async Task<string> EditMember(EditMemberDTO param)
        {
            var result = await _memberBLL.EditMember(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 获取会员列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpGet, Route("GetMemberList")]
        public async Task<string> GetMemberList(GetListDTO param)
        {
            var result = await _memberBLL.GetMemberList(param);
            return result.ToJsonFormat();
        }
    }
}
